home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: howland.reston.ans.net!torn!nott!emr1!news
- From: Stephane Charette <charrick@netrover.com>
- Subject: Opening STDOUT As BINARY
- X-Nntp-Posting-Host: pc20.ccg.emr.ca
- Content-Type: text/plain; charset=us-ascii
- Message-ID: <3161CAD8.296C@netrover.com>
- Sender: news@emr1.emr.ca
- Content-Transfer-Encoding: 7bit
- Organization: Natural Resources Canada, Ottawa
- Mime-Version: 1.0
- Date: Wed, 3 Apr 1996 00:48:24 GMT
- X-Mailer: Mozilla 2.01 (Win16; I)
-
- I've come across a problem, and I believe that it is
- caused by limitations in C/C++. Can anyone help on the
- following:
-
- I need to output binary information to the console, which
- is then redirected to a file by the o/s. At the moment,
- I'm using printf( "%c", mychar ) to output the the binary
- data one character at a time as it comes in.
-
- However, it seems that the character #7 (0x07, bell) gets
- sent to stdout followed by an automatic CR (0x0A). Every
- other character in the ASCII table works fine! Is there
- a way to reopen stdout in binary mode instead of as a text
- stream? The extra 0x0A characters are corrupting the data!
-
- I've also tried "cout" and "putc", but they yield the same
- result.
-
- Why do I need this: this application runs as a CGI-BIN,
- and the web server EXPECTS the output to be sent to
- stdout. I cannot fwrite() this information to a physical
- file since the web server is capturing the console output!
-
- Thanks for any help,
-
- Stephane Charette.
-